package com.ysccc.shares.web;

import java.io.IOException;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ysccc.tools.Dates;
import com.ysccc.tools.Encodes;

@RestController
@RequestMapping("/export/data")
public class ExportDataController {

	@GetMapping("/excel")
	public void exportExcel(HttpServletRequest request, HttpServletResponse response) {
		// 设置reponse的文件属性
		response.setHeader("Content-disposition", "attachment; filename="+ Encodes.urlEncode(Dates.format(Dates.now()) + "收盘结果.xlsx"));  
		response.setContentType("application/vnd.ms-excel;charset=utf-8");
		response.setCharacterEncoding("utf-8");
		// 写数据
		try (Workbook wb = new XSSFWorkbook();ServletOutputStream out = response.getOutputStream();) {
			
		} catch (IOException e) {
			throw new RuntimeException("输出excel失败");
		}
	}
}
